/*
 * Character_test.cpp
 *
 *  Created on: Apr 24, 2014
 *      Author: GW
 */

#include "src/TestMacros.h"
#include "src/CheckMacros.h"
#include "src/TestRunner.h"
#include "src/TimeConstraint.h"
#include "src/ReportAssert.h"
#include "Character/Character.h"
#include "Map/GameMap.h"


using namespace UnitTest;

SUITE(Character)
{
	TEST(Initialized)
	{
		Character* myCharacter = Character::getInstance();
		myCharacter->init("Game/Character/[Human][Engineer] (100).png", GameMap::getInstance());

		bool isCharacterInitialized = myCharacter->getObstacleHitChance() != 0;
		CHECK_EQUAL(isCharacterInitialized, true);

		//cleanup
		//Character::deleteInstance();
	}



	TEST(UpdateDirectorObstacle)
	{
		Character::resetInstance();
		Character* myCharacter = Character::getInstance();
		myCharacter->init("Game/Character/[Human][Engineer] (100).png", GameMap::getInstance());


		//check valid update
		myCharacter->updateDirectorObstacle(30);
		bool isUpdated = myCharacter->getObstacleHitChance() == 30;
		CHECK_EQUAL(isUpdated, true);

		//check maximum limit
		myCharacter->updateDirectorObstacle(101);
		isUpdated = myCharacter->getObstacleHitChance() == 101;
		CHECK_EQUAL(isUpdated, false);

		//check minimum limit
		myCharacter->updateDirectorObstacle(-1);
		isUpdated = myCharacter->getObstacleHitChance() == -1;
		CHECK_EQUAL(isUpdated, false);

		//Character::deleteInstance();
	}

	TEST(UpdateSpeedMultiplier)
	{
		Character::resetInstance();
		Character* myCharacter = Character::getInstance();
		myCharacter->init("Game/Character/[Human][Engineer] (100).png", GameMap::getInstance());


		//check valid update
		myCharacter->updateDirectorSpeed(2.0);
		bool isUpdated = myCharacter->getSpeedMultiplier() == 2.0;
		CHECK_EQUAL(isUpdated, true);

		//check minimum limit
		myCharacter->updateDirectorSpeed(-2.0);
		isUpdated = myCharacter->getSpeedMultiplier() == -1;
		CHECK_EQUAL(isUpdated, false);

		//Character::deleteInstance();
	}

	/*TEST(reduceHealth)
	{
		Character::resetInstance();
		Character* myCharacter = Character::getInstance();
		myCharacter->init("Game/Character/[Human][Engineer] (100).png", GameMap::getInstance());

		int originalHealth = myCharacter->getHealth();
		//not immune before reduce health
		CHECK_EQUAL(myCharacter->isImmune(), false);

		//check reduce -1 health
		myCharacter->reduceHealth(-1);
		bool isHealthReduced = myCharacter->getHealth() > originalHealth - 1;
		CHECK_EQUAL(isHealthReduced, false);

		//check reduce 1 health
		myCharacter->reduceHealth(1);
		isHealthReduced = myCharacter->getHealth() == originalHealth -1;
		CHECK_EQUAL(isHealthReduced, true);
		CHECK_EQUAL(myCharacter->isImmune(), true);
		originalHealth = myCharacter->getHealth();

		//check reduce health while immune
		myCharacter->reduceHealth(1);
		isHealthReduced = myCharacter->getHealth() > originalHealth -1;
		CHECK_EQUAL(isHealthReduced, false);

		Character::deleteInstance();
	}*/


}



